<%-- 
    Document   : Map thing
    Created on : 21/08/2011, 11:23:51 AM
    Author     : Lewis Kelly
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ include file="../header.jsp" %>
<link rel="stylesheet" type="text/css" href="../style.css"/>
<div id="content-container">
    <div id="content">
        <style type="text/css">
            #map{
                margin-left:80px;
            }
            
            #baaa{
                margin-left: 80px;
            }
        </style>
        <h3>Choose Location</h3>
        <form:form NAME="locationForm" METHOD="POST" commandName="location">

            <form:input path="latitude" class="required" type="text" name="latitude" id="latitude" value="-27.49571" hidden="true" /> 
            <form:input path="longitude" class="required" type="text" name="longitude" id="longitude" value="153.012772" hidden="true" />
            <br />
            <div id="map" style="width: 600px; height: 420px"></div>

            <!-- add your map api key here -->
            <script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key="></script>

            <script type="text/javascript">
               
                function returnCoords(){
                    var name = document.getElementById('name').value;
                    if (name == ""){
                        alert("Enter Place Name");
                        return false;
                    }
                    
                    var lat = document.assignForm.latitude.value;
                    var lng = document.assignForm.longitude.value;
                    alert(''+lat+' '+lng);
                    
                    
                    return true;
                    
                }
                
                function add(){
                    document.getElementById("msg").innerHTML += "<p>Hi Mark</p>";
                }
                
                <!--
                if (GBrowserIsCompatible()) 
                {
                    // create map and add controls
                    var map = new GMap2(document.getElementById("map"));
                    var customUI = map.getDefaultUI();
                    customUI.controls.scalecontrol = false;
                    map.setUI(customUI);
                    map.addControl(new GLargeMapControl());        
                    map.addControl(new GMapTypeControl());
	
                    // set centre point of map
                    var centrePoint = new GLatLng('-27.49571', '153.012772');
                    map.setCenter(centrePoint, 14);	
	
                    // add a draggable marker
                    var marker = new GMarker(centrePoint, {draggable: true});
                    
                    map.addOverlay(marker);
	
                    // add a drag listener to the map
                    GEvent.addListener(marker, "dragend", function() {
                        var point = marker.getPoint();
                        map.panTo(point);
                        document.getElementById("latitude").value = point.lat();
                        document.getElementById("longitude").value = point.lng();
                    });
                }
                //-->
            </script>
            <br /><br/>
            <%Object temp = request.getParameter("pid");%>
            <span hidden="true">
                <form:input path='pollID' type='text' value='<%=temp%>'/>
            </span>
            <%--<b>Enter Place Name: </b><form:input path="name" type="text" name="name" id="name" />--%>
            <input id="baaa" type="submit" onclick="returnCoords()" value="Add Location"  />






        </form:form>
        <p> <input type="button" value="Back" onClick="javascript: history.go(-1)"></p>
    </div>
</div>		

<%@ include file="../footer.jsp" %>
